import api from './index'
import { axios } from '@/utils/request'

// permissionUrl: '/ums-api/ums/permission/'

/**
 * 路由
 * // ums
    {
        path: '/ums',
        name: 'ums',
        component: PageView,
        redirect: '/ums/permission',
        meta: { title: '后台用户权限表', icon: 'table', permission: [ 'ums' ] },
        children: [
            {
                path: '/ums/permission',
                name: 'Permission',
                component: () => import('@/views/ums/PermissionList'),
                meta: { title: '后台用户权限表', keepAlive: true, permission: [ 'permission' ] }
            }
        ]
    },
 */
/**
 * 查询权限树
 * @param id
 * @returns {*}
 */
export function getPermissionTree () {
    return axios({
        url: api.permissionTreeUrl,
        method: 'get'
    })
}

/**
 * 查询列表
 * @returns {*}
 */
export function getPermissionList (parameter) {
    return axios({
        url: api.permissionUrl,
        method: 'get',
        data: parameter
    })
}

/**
 * 查询详情
 * @param id
 * @returns {*}
 */
export function getPermission (id) {
    return axios({
        url: api.permissionUrl + id,
        method: 'get'
    })
}

/**
 * 更新
 * @param id
 * @param parameter
 * @returns {*}
 */
export function updatePermission (id, parameter) {
    return axios({
        url: api.permissionUrl + id,
        method: 'put',
        data: parameter
    })
}

/**
 * 新增
 * @param parameter
 * @returns {*}
 */
export function addPermission (parameter) {
    return axios({
        url: api.permissionUrl,
        method: 'post',
        data: parameter
    })
}

/**
 * 删除
 * @param id
 * @returns {*}
 */
export function deletePermission (id) {
    return axios({
        url: api.permissionUrl + id,
        method: 'delete'
    })
}

/**
 * 批量删除
 * @param id
 * @returns {*}
 */
export function batchDeletePermission (parameter) {
    return axios({
        url: api.permissionUrl + 'delete/batch',
        method: 'post',
        data: parameter
    })
}
/**
 * 更新按钮权限
 * @param id
 * @returns {*}
 */
export function updateOperatePermission (parameter) {
    return axios({
        url: api.updateOperatePermissionUrl,
        method: 'post',
        data: parameter
    })
}
